from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication,QWidget,QHBoxLayout,QVBoxLayout
from PyQt5.QtWidgets import QPushButton,QLineEdit,QMessageBox
import sys


def on_delete_click():
    print("弹出删除确定对话框")
    #QMessageBox.information(w,"删除用户","确定要删除用户吗?")
    result = QMessageBox.question(w,"删除用户","确定要删除用户吗?",
                                  buttons=QMessageBox.Yes | QMessageBox.Cancel,
                                  defaultButton=QMessageBox.Cancel)
    if result == QMessageBox.Yes:
        print("删除用户")
    else:
        print("取消删除")
    
    print(result)
    
    #给按钮添加/关联点击事件（函数）
if __name__ == '__main__':
    # 创建应用程序
    app = QApplication(sys.argv)
    # 创建窗口
    w = QWidget()
    #设置窗口标题
    w.setWindowTitle("布局嵌套")
    w.resize(500,500)
    #  创建水平布局 HorizontalLayout    垂直布局 VerticalLayout
    root_layout = QHBoxLayout(w)
    btn = QPushButton("删除用户")
    btn.clicked.connect(on_delete_click)    
    root_layout.addWidget(btn)
   
    
    
    #显示窗口
    #提交  
    w.show()

    #等待窗口停止
    sys.exit(app.exec())